package com.xiaobai.common.utils.result;


import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class ServiceException extends RuntimeException {
    private ResultCode resultCode;
    private String msg;

    public ServiceException() {
        this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
    }

    public ServiceException(String message) {
        super(message);
        this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
        this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
    }

    public ServiceException(Throwable cause) {
        super(cause);
        this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
    }

    protected ServiceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
    }

    public ServiceException(ResultCode resultCode) {
        super(resultCode.getMes());
        this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
        this.msg = resultCode.getMes();
    }

    public ServiceException(ResultCode resultCode, String message) {
        super(message);
        this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
        this.msg = message;
    }

    public ServiceException(ResultCode resultCode, String message, Throwable e) {
        super(message, e);
        this.resultCode = ResultCode.INTERNAL_SERVER_ERROR;
    }

}